<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>积分后台管理</title>

		<link rel="icon" href="img/lei_huiyuan_on.png"  size="16x16" />
	</head>
	<body>
<div id="top">

</div>
		<div class="body content"  id="app">
			<div id="left">

			</div>

			<div class="right">

				<div class="liebie_title style_hei_16">
					<img src="img/xiugai.png">生成二维码
				</div>
        <div class="bottom">

            <div class="zijin_zhuru_top style_hei_14">
                <div class="zijin_zhuru_list zijin_zhuru_list_daili">
                   <p><span class="style_hong_12">*</span>积分：</p><input type="text" name="" v-model="jifen" placeholder="请输入积分" class="add_xuan"/>
                </div>
				<div class="zijin_zhuru_list zijin_zhuru_list_daili">
				    <!-- <span class="fenzhan_name">品牌LOGO:</span> -->
					<p><span class="style_hong_12"></span>品牌LOGO：</p>
				    <div class="img_zheng">
				        
						<div class="img_zheng_item" v-if="logo">
							<img :src="logo" alt="" />
							<span class="img_dl" @click="logo=''"></span>
						</div>
				    </div>
				    <div class="up_logo">
				        <input type="file" name="" id="shenfen_zheng" value="" @change="upload_zheng()"/>
				    </div>
				    <!-- <p class="style_hui_12">请上传尺寸为 （149*50） 的图片</p> -->
				</div>
				<div class="zijin_zhuru_list zijin_zhuru_list_daili">
				    <p>&ensp;&ensp;<span class="style_hong_12">*</span>数量：</p><input type="text" v-model="num" placeholder="请输入数量" class="add_xuan"/>&ensp;张
				</div>
				<div class="zijin_zhuru_list zijin_zhuru_list_daili">
				    <p>&ensp;&ensp;<span class="style_hong_12"></span>简介：</p><input type="text" v-model="jianjie" placeholder="请输入简介" class="add_xuan"/>
				</div>
                <div class="queren_tijiao " @click="tijiao()">
                    确认
                </div>
            </div>




   


        </div>
			</div>
		</div>
<script src="js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="laydate/laydate.js" type="text/javascript" charset="utf-8"></script>
<script src="js/selectFilter.js" type="text/javascript" charset="utf-8"></script>
<script src="js/get.js" type="text/javascript" charset="utf-8"></script>
<script src="js/gong.js"></script>
<script src="js/fengzhuang.js"></script>
<script src="js/vue.js"></script>
<script>
	var app = new Vue({
	    el: '#app',
	    data:{
	        list :[],
			page:1,
			limit:10,
			pageCount:0,
			jifen:'',
			logo:'',
			num:1,
			jianjie:''
	    },
		mounted(){
			
		},
		methods:{
			xuanye(page){
				this.page=page
				this.get_list()
			},
			get_list(){
			    $.ajaxDirect("/api/getAllProducts",'get',{
			    	'page':this.page,
			    	'limit':this.limit
			    },
			     (obj)=> {
			    		  if(obj.code==200){
			    			  
			    			  this.list=obj.list
							  this.pageCount=Math.floor(Number(obj.totalCount)/this.limit)

			    		  }
			    },
			    (err)=> {
			            //发送失败
			    })
			},
			tijiao() {
			    if (!this.jifen) {
			        layer.msg('请输入积分')
			        return false;
			    }
			    // if (!this.logo) {
			    //     layer.open({content: '请选择公告类型'});
			    //     return false;
			    // }
			    if (!this.num) {
			        layer.msg('请输入生成数量')
			        return false;
			    }
				// if (!this.num) {
				//     layer.open({content: '请输入公告内容'});
				//     return false;
				// }
			    
			   $.ajaxDirect('/api/createQrCode','post',{
				   points:this.jifen,
				   logo:this.logo,
				   num:this.num,
				   description:this.jianjie
			   },
			    (obj)=> {
			   		  if(obj.code==200){
			   			  
			   			 layer.msg(obj.message)
			   			 setTimeout(()=>{
			   				 history.go(0);
			   				 
			   			 },500)
			   
			   		  }
			   },
			   (err)=> {
			           //发送失败
			   })
			},
			upload_zheng() {
				 var that=this
				 var fileImgs=$("#shenfen_zheng")[0].files
				 
				   
				 for(var i=0; i<fileImgs.length; i++){
				 	    // shuangchuan(fileImgs[i],i)
						var formData = new FormData();
						formData.append("file", fileImgs[i]);
						$.ajax({
						        url: 'http://120.55.77.106:3000/api/upload',  
						        type: 'POST',  
						        data: formData,  
						        dataType: 'JSON',  
						        cache: false,  
						        processData: false,  
						        contentType: false,
						        success : function(data) {
						            if(data.code==200){
										that.logo=data.fileUrl
									}
						        },
						        error:function(){
						            alert("上传失败");
						        }
						    });
				                             
				     }
			
			}
	
		}
		
	})	
</script>


	</body>
</html>